import {
    INCREMENTCOUNT,
    DECREMENTCOUNT
} from '../constnant/countConst'

const init = {
    count: 0,
    a: 1
}

export default function countReducer(prevState = init, action) {
    
    const {
        type,
        data
    } = action

    switch (type) {
        case INCREMENTCOUNT:
            return {
                ...prevState, count: prevState.count + data
            }
        case DECREMENTCOUNT:
            return {
                ...prevState, count: prevState.count - data
            }
    }

    return prevState
}